package com.yeban.javase.day20.test.test5.statics;

/**
 * @Desc TODO
 * @Author yeban
 * @Date 2025/11/6
 */
public class StaticCalculator implements ICalculator{

    private ICalculator target;

    public StaticCalculator(ICalculator target) {
        this.target = target;
    }

    // 加
    @Override
    public int add(int a, int b) {
        System.out.println("开始日志追踪：The Method login begin with [a = " + a + ", b = " + b + "]");
        long l1 = System.currentTimeMillis();
        int num = target.add(a, b);
        long l2 = System.currentTimeMillis();
        System.out.println("结束日志追踪：The Method login end with , 耗时" + (l2-l1) + "ms");
        return num;
    }

    // 减
    @Override
    public int subtract(int a, int b) {
        System.out.println("开始日志追踪：The Method login begin with [a = " + a + ", b = " + b + "]");
        long l1 = System.currentTimeMillis();
        int num = target.subtract(a, b);
        long l2 = System.currentTimeMillis();
        System.out.println("结束日志追踪：The Method login end with , 耗时" + (l2-l1) + "ms");
        return num;
    }

    // 乘
    @Override
    public int multiply(int a, int b) {
        System.out.println("开始日志追踪：The Method login begin with [a = " + a + ", b = " + b + "]");
        long l1 = System.currentTimeMillis();
        int num = target.multiply(a, b);
        long l2 = System.currentTimeMillis();
        System.out.println("结束日志追踪：The Method login end with , 耗时" + (l2-l1) + "ms");
        return num;
    }

    // 除
    @Override
    public int divide(int a, int b) {
        System.out.println("开始日志追踪：The Method login begin with [a = " + a + ", b = " + b + "]");
        long l1 = System.currentTimeMillis();
        int num = target.divide(a, b);
        long l2 = System.currentTimeMillis();
        System.out.println("结束日志追踪：The Method login end with , 耗时" + (l2-l1) + "ms");
        return num;
    }
}
